//
//  CWNetWork.h
//  CWDevelop
//
//  Created by LittoCats on 7/15/14.
//  Copyright (c) 2014 Littocats. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CWNetWork : NSObject

/**
 *  post 请求
 */
+ (void)post:(NSString *)urlString
      params:(NSDictionary *)params
completionHandler:(void (^)(NSDictionary *response, NSError *error))handler;

/***
*   get 请求
 */
+ (void)get:(NSString *)urlString
      params:(NSDictionary *)params
completionHandler:(void (^)(NSDictionary *response, NSError *error))handler;

/**
 *  下载
 */
+ (void)download:(NSString *)urlString
          params:(NSDictionary *)params
completionHandler:(void (^)(NSString *response, NSError *error))handler;

/**
 *  获取当前IPv4地址
 */
+ (NSString *)getIPAddress:(BOOL)preferIPv4;

/**
 *  ping
 */
+ (void)ping:(NSString *)urlString handler:(void (^)(NSString *status))handler;

/**
 *  debug info
 */
+ (void)analyseDebugServer:(void (^)(NSURL *serverURL))completionHandler;
@end

@interface CWNetWorkSecurity : NSObject

+ (void)willAccessNetRequestWithURL:(NSURL **)url params:(NSDictionary **)params;

@end

//UDP 监听3001端口，获取debug url
@interface CWNetWorkDebugger : NSObject

@property (nonatomic, readonly) NSURL *debugURL;

+ (void)analyseDebugServer:(void (^)(NSURL *serverURL))completionHandler;

@end


@interface UIImageView (CWNet)

- (void)setImageURL:(NSURL *)imageURL
    withPlaceholder:(UIImage *)placeholder
  completionHandler:(void (^)(UIImage *image))handler;

@end